{include file="common/mini-header" title="权限节点"}
<div class="layui-body">
	<!-- 内容主体区域 -->

	<form class="layui-form" action="" style="max-width: 800px;width: 90%;">
		<div class="layui-form-item">
			<label class="layui-form-label">父级</label>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="pid" lay-verify="required"> 
					{:buildRoleSelect(0)}
				</select>
			</div>
		</div>		
		<div class="layui-form-item">
			<label class="layui-form-label">角色名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" required lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-inline">
				<input type="text" name="sort" class="layui-input" value="0" />
			</div>
			<div class="layui-form-mid layui-word-aux">逆序</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="addMenu">添加</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

</div>
<script>
	layui.use('form', function() {
		var form = layui.form;
		var $ = layui.jquery;
		var layer = layui.layer;

		//监听提交
		form.on('submit(addMenu)', function(data) {
			$.post('./add', data.field, function(rs) {
				if (rs.code == 1) {
					window.location.href = rs.url
				} else {
					layer.alert(rs.msg)
				}
			})
			return false;
		});
	});
</script>
{include file="common/footer"}
